<?php

$s_turma = new Zend_Session_Namespace('Turma');


function actionMenu($controller,$menu){
    echo $class = ($controller == $menu) ? 'class="action"':'';
}
function actionSeta($controller,$menu){
    echo $class = ($controller == $menu) ? '<span>&#9660;</span>':'<span>&nbsp;</span>';
}

//aluno
if($this->storage->read()->TUS_ID == 2){ 

    $sessao = new Zend_Session_Namespace('Aluno');

    Zend_Loader::loadClass('aluno','library'); 
    Zend_Loader::loadClass('dominio','library');

    $db = Zend_Db_Table_Abstract::getDefaultAdapter();
    $query = 'SELECT SQL_CACHE n.NRT_NOM,cb.CBS_NOM,c.TUR_ID,c.CUR_ANO,c.CUR_SEM '
            .' FROM MATRICULA m, CURSOBASE cb, CURSO c, NUMEROTURMA n '
            .' WHERE m.ALU_ID = '.$sessao->aluno['ALU_ID'].' '
            .' AND m.CUR_ID = c.CUR_ID AND c.CBS_ID = cb.CBS_ID AND c.CUR_TRM = n.NRT_ID '
            .' AND m.MAT_STA = 1';
    $row = $db->fetchRow($query);
    
    // 2º par -> .' | '.dominio::getTurno($row['TUR_ID'])
    if(isset($row['NRT_NOM'])) $turma = $row['CBS_NOM'].' | '.$row['NRT_NOM'].' | '.$row['CUR_ANO'].' | '.dominio::getSemestres($row['CUR_SEM']);
    else $turma = '';
?>

    <div class="st-tp-menu">
        <div class="content-it-br"> 
            <?php
                $img = glob('public/upload/aluno/'.$sessao->aluno['ALU_ID'].'_ead.*'); 
                if(!isset($img[0])) $img[0] = 'public/media/images/aluno_ead.png';
            ?>
            <a class="itl-conf" href="<?php echo $this->baseUrl($this->modulo.'/minhaconta/foto'); ?>">
                <img src="<?php echo $this->urlbase;?>/<?php echo $img[0]; ?>" />
            </a>

            <div class="br-usuario">
                <div class="nome"><?php echo $this->storage->read()->USU_NOME; ?></div>
                <?php /* ?><span><strong>Status: <?php echo strtoupper(aluno::returnStatusAluno($sessao->aluno['ALU_ID'])); ?></strong></span>  <?php */ ?>
                <span><strong>Turma: <?php echo $turma; ?></strong></span>
            </div>

            <a class="itr-sair" onclick="if(confirm('Deseja sair?')) location = '<?php echo $this->baseUrl($this->modulo.'/auth/logout')?>';" href="javascript:void(0)">Sair</a>
            <a class="itr-conf" href="<?php echo $this->baseUrl($this->modulo.'/minhaconta'); ?>"></a>
            
        </div>
    </div>

    <?php 
    $imgs = glob('public/upload/eadbanner/*');
    if(isset($imgs[0])){

        $sessao = new Zend_Session_Namespace('banner');

        if($sessao->id == '') $sessao->id = 0;
        $total = count($imgs) - 1;
        //$rand = rand(0, $total);
        $rand = $sessao->id;
        $img = $imgs[$rand];

        if($sessao->id >= $total) $sessao->id = 0;
        else $sessao->id = $sessao->id + 1;

        if($img > ''){
    ?>

        <?php /* <img src="<?php echo $this->urlbase.'/'.$img; ?>" height="200px" width="100%" /> */ ?>
        <div class="banner" style="background-image: url('<?php echo $this->urlbase.'/'.$img; ?>');"></div>
    <?php
        } 
    } 
    ?>

    <div class="st-menu"> 
        <ul>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/'); ?>" <?php echo actionMenu($this->controller,'index');?>>Início <?php echo actionSeta($this->controller,'index');?></a></li>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/materiais'); ?>" <?php echo actionMenu($this->controller,'materiais');?>>Materiais <?php echo actionSeta($this->controller,'materiais');?></a></li>
            <?php if($s_turma->turma['CUR_REDENV'] > 0){ ?>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/redacao'); ?>" <?php echo actionMenu($this->controller,'redacao');?>>Redação <?php echo actionSeta($this->controller,'redacao');?></a></li>
            <?php } ?>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/linkuteis'); ?>" <?php echo actionMenu($this->controller,'linkuteis');?>>Links Úteis <?php echo actionSeta($this->controller,'linkuteis');?></a></li>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/contato'); ?>" <?php echo actionMenu($this->controller,'contato');?>>Contato <?php echo actionSeta($this->controller,'contato');?></a></li>
        </ul>
    </div>
    
<?php 
}else //professo
if($this->storage->read()->TUS_ID == 3){

    
function actionMenuPrf($controller,$menu){
    echo $class = ($controller == $menu) ? 'class="action"':'';
}

$sessao = new Zend_Session_Namespace('Professor');
?>
    
    <div class="st-tp-menu">
        <div class="content-it-br"> 
            <?php
                //$img = glob('public/upload/aluno/'.$sessao->aluno['ALU_ID'].'_ead.*'); 
                $img = array();
                if(!isset($img[0])) $img[0] = 'public/media/images/aluno_ead.png';
            ?>
            <a class="itl-conf" href="javascript:void(0);">
                <img src="<?php echo $this->urlbase;?>/<?php echo $img[0]; ?>" />
            </a>

            <div class="br-usuario">
                <div class="nome"><?php echo $this->storage->read()->USU_NOME; ?></div>
                <span><strong><?php echo $sessao->professor['DCP_NOM'].' | '.$this->parametros['PAR_NOM']; ?></strong></span>
            </div>

            <a class="itr-sair" onclick="if(confirm('Deseja sair?')) location = '<?php echo $this->baseUrl($this->modulo.'/auth/logout')?>';" href="javascript:void(0)">Sair</a>
            <?php if(strlen($this->parametros['PAR_FAC']) > 0){ ?>
            <a class="itr-face" href="<?php echo $this->parametros['PAR_FAC']; ?>"></a>
            <?php } ?>
            <a class="itr-conf" href="<?php echo $this->baseUrl($this->modulo.'/minhaconta'); ?>"></a>

        </div>
    </div>

    <div class="st-menu-prf"> 
        <ul>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/'); ?>" <?php echo actionMenuPrf($this->controller,'index');?>>Mural</a></li>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/repositorio'); ?>" <?php echo actionMenuPrf($this->controller,'repositorio');?>>Meus Conteúdos</a></li>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/publicacao'); ?>" <?php echo actionMenuPrf($this->controller,'publicacao');?>>Publicar Tópicos</a></li>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/enviarlinks'); ?>" <?php echo actionMenuPrf($this->controller,'enviarlinks');?>>Publicar Links</a></li>
            <li><a href="<?php echo $this->baseUrl($this->modulo.'/contatoprf'); ?>" <?php echo actionMenuPrf($this->controller,'contatoprf');?>>Contato</a></li>
        </ul>
    </div>
<?php } ?> 